<!DOCTYPE HTML>
<html>
<head>
    {include file='common_header'}
    <title>用户列表</title>
</head>
<body>
<nav class="breadcrumb">
    <i class="Hui-iconfont">&#xe67f;</i> 首页
    <span class="c-gray en">&gt;</span> 用户管理 <span class="c-gray en">&gt;</span>用户列表
    <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href='javascript:location.replace(location.href="{:Url('showlist')}");' title="刷新" >
        <i class="Hui-iconfont">&#xe68f;</i>
    </a>
</nav>
<div class="page-container">
    <div class="cl pd-5 bg-1 bk-gray">
        <a href="javascript:;" onclick="layer_show('添加用户','{:url('showadd')}', '550','350')" class="btn btn-primary radius">
            <i class="Hui-iconfont">&#xe600;</i> 添加用户
        </a>
        <div style="float: right">
            <label>真实姓名/昵称：</label>
            <input type="text" class="input-text" style="width:250px" placeholder="请输入用户真实姓名/昵称" id="keywords" value="{$Think.get.keyword}">
            <button type="button" class="btn btn-success" onclick="reload($('#keywords').val())"><i class="Hui-iconfont">&#xe665;</i> 搜索</button>
        </div>
        <table class="table table-border table-bordered table-bg">
            <thead>
            <tr>
                <th scope="col" colspan="10"></th>
            </tr>
            <tr class="text-c">
               <!-- <th width="25"><input type="checkbox" name="" value=""></th>-->
                <th width="40">ID</th>
                <th width="40">用户头像</th>
                <th width="90">登录名</th>
                <th width="90">用户昵称</th>
                <th width="80">真实姓名</th>
                <th width="80">推荐人</th>
                <th width="130">注册时间</th>
                <th width="100">用户状态</th>
                <th width="100">操作</th>
            </tr>
            </thead>
            <tbody>
            {volist name="user" id="v"}
            <tr class="text-c">
               <!-- <td><input type="checkbox" value="{$v->id}" name="" class="item"></td>-->
                <td>{$v->id}</td>
                <td><img src="__UPS__{$v->user_avator}" style="width: 50px;"/></td>
                <td>{$v->username}</td>
                <td>{$v->user_nickname}</td>
                <td>{$v->user_realname}</td>
                <td>{$v->refreeid->user_realname}</td>
                <td>{$v->addtime|date='Y-m-d H:i:s',###}</td>
                <td class="td-status"   onclick="adminstatus({$v->id},{$v->user_status})">
                {if condition="$v->user_status eq 1"}
                <span class="label label-success radius" >已启用</span>
                {else /}
                <span class="label radius" style="background:red">已停用</span>
                {/if}
                </td>
                <td class="td-manage">
                    <a title="查看详情"  onclick="layer_show('用户详情','{:url('showdetails',array('id'=>$v['id']))}','800','450')"  class="btn btn-primary radius"style="text-decoration:none;" >
                        <i class="Hui-iconfont">&#xe725;</i>
                    </a>
                    <!--<a title="编辑" href="javascript:;" onclick="layer_show('管理员编辑','{:url('showEdit',array('id'=>$v['id']))}','650','550')" class="ml-5" style="text-decoration:none">
                        <i class="Hui-iconfont">&#xe6df;</i>
                    </a>-->
                   <!-- <a title="删除" href="javascript:;" onclick="delectOne('{:url('del',array('id'=>$v['id']))}',this)" class="ml-5" style="text-decoration:none">
                        <i class="Hui-iconfont">&#xe6e2;</i>
                    </a>-->
                    <a title="重置密码" onclick="referpass({$v->id})" style="text-decoration: none" class="btn btn-danger radius">
                        <i class="Hui-iconfont">&#xe63f;</i>
                    </a>
                </td>
            </tr>
            {/volist}
            </tbody>
        </table>
        <div class="page">
            {$page}
        </div>
    </div>
    <!--_footer 作为公共模版分离出去-->
    {include file='common_footer'}
    <!--/_footer 作为公共模版分离出去-->
</div>
</body>
<script>
    function reload(obj) {
        goUrl('?keyword=' + obj);
    }
    /*管理员-重置密码*/
    function referpass(id){
        layer.confirm('确认要将密码重置为a123456吗？',function(index){
            $.ajax({
                type: 'POST',
                url: "{:url('refresspwd')}",
                data:{id:id},
                dataType: 'json',
                success: function(data){
                    layer.msg(data.msg,{icon:1,time:1000},function () {
                        location.reload();
                    });

                },
                error:function(data) {
                    console.log(data.msg);
                },
            });
        });
    }
    function adminstatus(id,user_status) {
        if(user_status==1){
            $msg="确认要停用该用户吗？";
        }else{
            $msg="确认要开启该用户吗";
        }
        layer.confirm($msg,function(){
            $.ajax({
                type: 'POST',
                url: "{:url('editstatus')}",
                data:{id:id,user_status:user_status},
                dataType: 'json',
                success: function(data){
                    layer.msg(data.msg,{icon:1,time:1000},function () {
                        location.reload();
                    });
                },
                error:function(data) {
                    console.log(data.msg);
                },
            });
        });

    }
</script>
</html>